import { getOrderChartData } from '../services/api';

export default {
  namespace: 'orderChart',

  state: {
    orderData : [],
  },

  effects: {
    *fetchOrderData({ payload }, { call, put }) {
      const response = yield call(getOrderChartData, payload);
      yield put({
        type: 'save',
        payload: {
          orderData : response
        },
      });
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
        orderData : []
      };
    },
  },
};
